import numpy as np
import os
from EAattak.BaseSample import BaseSampleGeneration

# Target Base Sample Attack
class TBS:

    def __init__(self, dataer, neter, config):

        self.dataer = dataer
        self.neter = neter
        self.config = config
        self.bs_generator = BaseSampleGeneration(dataer=dataer, neter=neter, config=config)


    def attck(self, sample, origin_label, target_label):
        """
        sample: (torch.tensor)
        origin_label: (int)
        target_label: (int)
        """
        if origin_label == target_label:
            raise Exception('Origin label equals to target label !')
        
        bs_samples = self.bs_generator.get_BaseSample(class_index=target_label)

    def Combined_floating_attck(self, ):
        """
        邻域思想，优化基样本扰动的组合,以浮点数的形式给出
        """
        pass

    def Combined_direction_attck(self, ):
        """
        邻域思想，优化基样本扰动的组合，以无穷范数为为攻击方式，通过sign，找攻击方向
        """
        pass

    def Floating_attck(self, ):
        """
        直接用于生成初始种群，通过进化策略，找更好的扰动
        """
        pass

    def Direction_attck(self, ):
        """
        利用sign化为方向，也是用于直接生成种群， 然后进化策略去解决。
        """
        pass
